import { getSchemaTpl } from 'amis-editor';
import { getInputTpl } from '../base/util';
import { wrapperRender } from '../wrapperRender';
import { Panel } from '@cscec/udp-ui';
import React from 'react';


export default wrapperRender(({ title, body, render, fullScreen = true, collapsible = true }) => {
  return (
    <Panel title={title} fullScreen={fullScreen} collapsible={collapsible}>
      {render('body', body || {})}
    </Panel>
  );
}, {
  type: 'udp-panel',
  name: 'Panel容器',
  order: -7998,
  icon: 'LayoutOutlined',
  description: '包含标题，内容，可折叠属性的容器',
  scaffold: {
    title: '标题',
    fullScreen: true,
    collapsible: true
  },
  regions: [
    {
      key: 'body',
      label: '内容',
    }
  ],
  panelBodyCreator(context: any) {
    return getSchemaTpl('tabs', getSchemaTpl('commonTpl', {
      scope: this,
      context,
      groups: [
        {
          title: '基本属性',
          body: [
            getInputTpl('title', { label: "标题" }),
            getInputTpl('fullScreen', { type: "switch", label: "可全屏" }),
            getInputTpl('showFullScreen', { type: "switch", label: "可全屏" }),
            getInputTpl('collapsible', { type: "switch", label: "可折叠" })
          ],
        }
      ],
    }));
  },
});
